{	Problem: http://codeforces.ru/problemset/problem/88/B
 	Verdict: Accepted
}
uses SysUtils, Math;

const 
    eps:double=1e-12;
    
var 
    n,m,x,i,j,ls,cc,ii,imx,ans:longint;
    a:array[0..40,0..40] of char;
    cs:array[0..40,0..40] of longint;
        c,gd:array['a'..'z'] of boolean;
    sf:array[0..910,1..2] of longint;
    ch:char;
    s,t:string;
    f,sh:boolean;
    mx,dd:double;

function low(ch:char):char;
begin
if ch in ['A'..'Z'] then ch:=chr(ord(ch)+32);
result:=ch;
end;

function dist(a,b,c,d:longint):double;
var
    x1,y1,x2,y2,x,y:double;
begin
x1:=a-0.5;
y1:=b-0.5;
x2:=c-0.5;
y2:=d-0.5;
x:=x2-x1;
y:=y2-y1;
result:=x*x+y*y;
end;

begin
fillchar(sf,sizeof(sf),0);
fillchar(c,sizeof(c),false);
fillchar(gd,sizeof(gd),false);
readln(n,m,x);
sh:=false;
cc:=0;
for i:=1 to n do begin
    for j:=1 to m do begin
        read(a[i][j]);
        if a[i][j]='S' then begin
            sh:=true;
            inc(cc);
            sf[cc][1]:=i;
            sf[cc][2]:=j;
        end else c[a[i][j]]:=true;
    end;
    readln;
end;
readln(ls);
f:=true;
for i:=1 to ls do begin
    read(ch);
    s:=s+ch;
    if (not c[low(ch)]) or ((ch in ['A'..'Z']) and (not sh)) then begin
        f:=false;
        break;
    end;
end;
if f then begin
    ans:=0;
    t:='';
    for i:=1 to n do begin
        for j:=1 to m do begin
            if a[i][j]<>'S' then begin
                mx:=maxlongint;
                imx:=0;
                for ii:=1 to cc do begin
                    dd:=dist(i,j,sf[ii][1],sf[ii][2]);
                    if mx-dd>eps then mx:=dd;
                end;
                                if (sqrt(mx)-x>eps) and (not gd[a[i][j]]) then t:=t+a[i][j] else begin
                                    gd[a[i][j]]:=true;
                                    while pos(a[i][j],t)>0 do delete(t,pos(a[i][j],t),1);
                                end;
            end;
        end;
    end;
    for i:=1 to ls do
        if (pos(low(s[i]),t)>0) and (s[i] in ['A'..'Z']) then inc(ans);
    write(ans);     
end else write(-1);
end.